package com.yizisu.videolibrary

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import com.google.android.exoplayer2.MediaItem
import com.yizisu.playerlibrary.IYzsPlayer
import com.yizisu.playerlibrary.view.video_view.view.PlayerRootView

class TestVideoActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
        setContentView(R.layout.activity_test_video)
        val view = findViewById<PlayerRootView>(R.id.videoPlayer)
        val player = IYzsPlayer<IYzsPlayer.Model>(this,true)
        player.setAudioForceEnable(true)
        view.setPlayerAndInitHelper(player)
        view.post {
            player.prepare(mutableListOf(object : IYzsPlayer.Model() {
                override fun onMediaItem(uriCall: (MediaItem?, Throwable?, Boolean) -> Unit) {
                    uriCall.invoke(
                        MediaItem.fromUri("https://v-cdn.zjol.com.cn/276984.mp4"),
                        null,
                        false
                    )
                }

                override fun getTitle(): CharSequence? {
                    return "测试视频啊啊"
                }
            }), playWhenReady = false)
        }
    }

    fun toCachePage(view: View) {
        val intent = Intent(this, CacheActivity::class.java)
        startActivity(intent)
    }
}